home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple Developer Connection Student Program
/
ADC Tools Sampler CD Disk 3 1999.iso
/
Documentation
/
Books
/
Learn Java on the Macintosh
/
Learn Java Projects
/
08.01 - truth tester
/
TruthTester.java
< prev
next >
Wrap
Text File
|
1996-04-22
|
1KB
|
41 lines
/* -------------------------------------------------------------
This applet illustrates if-else statements.
Java's classes: Applet (applet)
System (lang)
Custom classes: TruthTester
------------------------------------------------------------- */
public class TruthTester extends java.applet.Applet {
public void init() {
boolean hasCar, hasTimeToGiveRide;
boolean nothingElseOn, newEpisode, itsARerun;
hasCar = true;
hasTimeToGiveRide = true;
if (hasCar && hasTimeToGiveRide)
System.out.println("Hop in - I'll give you a ride!");
else
System.out.println("I've either got no car, no time, or both!");
nothingElseOn = true;
newEpisode = true;
if (newEpisode || nothingElseOn)
System.out.println("Let's watch Star Trek!");
else
System.out.println("Something else is on or I've seen this one.");
nothingElseOn = true;
itsARerun = true;
if (nothingElseOn || (!itsARerun))
System.out.println("Let's watch Star Trek!");
else
System.out.println("Something else is on or I've seen this one.");
}
}